package com.alpaak.common.utils.mqtt;

import org.eclipse.paho.client.mqttv3.MqttMessage;


/**
* @ClassName: MQTTUtils 
* @Description: MQTT服务工具类
* @author eason
* @date 2018年2月5日 下午3:58:18
*/
public class MQTTUtils {

	/*
	 * 发布消息到mqtt服务器指定话题
	 */
	public static void publish(String pub,String topic){
		DcMqttServer server =  new DcMqttServer(topic);  
        server.message = new MqttMessage();  
        server.message.setQos(1);  
        server.message.setRetained(true);  
        server.message.setPayload(pub.getBytes());  
        server.publish(server.message);  
        //System.out.println(server.message.isRetained()+"------ratained状态");  
	}
	
	
	
}
